<?php
include_once "./interface/IController.php";
include_once "./view/View.php";
class PageController implements IController {
	private $view;
	
	public function __construct() {
		$this->view = new View ();
	}
	
	//设置方法的访问权限，若权限不匹配，则调用  forbidAction()
	public function getAccessRule(){
		return array(
			UserBean::$_ADMIN => array("home","courserequest"),
			UserBean::$_INSTITUE => array("home","courserequest"),
			UserBean::$_SENATE => array("home"),
			UserBean::$_GUEST => array("to404","index","about")
		);
	}
	public function indexAction() {
		redirectToAction ( 'user', 'login' );
	}
	
	public function homeAction() {
		$this->view->render ( "layout.php" );
	}
	public function courseRequestAction(){
		$this->view->render("course_request.php");
	}
	public function aboutAction() {
		$this->view->render ( "about.php" );
	}
	public function to404Action() {
		$this->view->render ( "404.php" );
	}
	
	//当请求的	action 不合法时调用此方法
	//重载 IController 接口
	public function forbidAction() {
		if(!islogin()) {
			redirectTo(urlToAction('user','login'));
		}
		$this->view->render ( "forbid.php" );
	}
}

?>